package androidx.fragment.app;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import com.gisocn.onemap.sgzx.R;

/* loaded from: classes.dex */
public abstract class BaseDialogFragment<T extends ViewDataBinding> extends DialogFragment {
    protected FragmentActivity _mActivity = null;
    protected Context context;
    protected T mViewDataBinding;
    protected ProgressDialog progressDialog;

    protected abstract void dismissEvent();

    protected abstract int getLayoutId();

    protected abstract void initListener();

    protected abstract void initView();

    protected abstract boolean isBottomDialog();

    protected abstract boolean isTopDialog();

    protected abstract boolean isTranslucentDialog();

    @Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
    public void onAttach(Context context) {
        super.onAttach(context);
        this._mActivity = getActivity();
        this.context = context;
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.mViewDataBinding = (T) DataBindingUtil.inflate(layoutInflater, getLayoutId(), viewGroup, false);
        initView();
        initListener();
        return this.mViewDataBinding.getRoot();
    }

    @Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (isBottomDialog()) {
            setStyle(2, R.style.MyBottomDialogStyle);
        } else if (isTopDialog()) {
            setStyle(2, R.style.MyTopDialogStyle);
        } else if (isTranslucentDialog()) {
            setStyle(2, R.style.MyMiddleDialogStyleTranslucent);
        } else {
            setStyle(2, R.style.MyMiddleDialogStyle);
        }
    }

    @Override // androidx.fragment.app.DialogFragment
    public void show(FragmentManager fragmentManager, String str) {
        if (Build.VERSION.SDK_INT <= 16 || !fragmentManager.isDestroyed()) {
            try {
                fragmentManager.beginTransaction().remove(this).commit();
                super.show(fragmentManager, str);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override // androidx.fragment.app.DialogFragment
    public void dismiss() {
        dismissEvent();
        super.dismiss();
    }

    @Override // androidx.fragment.app.Fragment
    public void onActivityResult(int i, int i2, Intent intent) {
        if (getChildFragmentManager().getFragments() == null || getChildFragmentManager().getFragments().size() <= 0) {
            return;
        }
        for (Fragment fragment : getChildFragmentManager().getFragments()) {
            fragment.onActivityResult(i, i2, intent);
        }
    }

    public void showProgressDialog() {
        showProgressDialog("数据加载中...");
    }

    public void showProgressDialog(CharSequence charSequence) {
        if (this._mActivity == null) {
            return;
        }
        if (this.progressDialog == null) {
            ProgressDialog progressDialog = new ProgressDialog(this._mActivity);
            this.progressDialog = progressDialog;
            progressDialog.setCanceledOnTouchOutside(false);
        }
        this.progressDialog.setMessage(charSequence);
        this.progressDialog.show();
    }

    public void closeLoadingDialog() {
        ProgressDialog progressDialog;
        if (this._mActivity == null || (progressDialog = this.progressDialog) == null || !progressDialog.isShowing()) {
            return;
        }
        this.progressDialog.dismiss();
    }
}
